<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>CCA费用</title>
<base href="<%=basePath%>">
<script type="text/javascript"
	src="plugins/websocketInstantMsg/ext4/ext-all-debug.js"></script>
<script type="text/javascript" src="static/js/jquery-1.7.2.js"></script>
<script type="text/javascript"
	src="plugins/websocketInstantMsg/ext4/locale/ext-lang-zh_CN.js"></script>
<link rel="stylesheet"
	href="plugins/websocketInstantMsg/ext4/resources/css/ext-all.css" />
</head>

<body>
<div id="div1" style="height:98px"></div>
<div id="aa"></div>
</body>
<script type="text/javascript">
Ext.onReady(function () {
	Ext.QuickTips.init();
    var store = Ext.create('Ext.data.Store', {
        fields:  ["ID","SETTLE_UNIT","BOX_MASTER","START_PORT","END_PORT","CURRENCY_TYPE","TAX_RATE","EXCHANGE_RATE","UNIT_PRICE",
                  "COLLECT_PAYMENT_SIGN","FRR_NAME","EMPTY_BOX","IMPORT_AND_EXPORT_SIGN","GOODS_TYPE","RIVER_BOAT_COMPANY","REMARK",
                  "ENABLE","ROUTE_CODE","BOX_TYPE_CODE", "REMARK","START_PRICE_TIME","END_PRICE_TIME",],
        pageSize: 10,  //页容量5条数据
        //是否在服务端排序 （true的话，在客户端就不能排序）
        remoteSort: false,
        remoteFilter: true,
        proxy: {
            type: 'ajax',
            url: '<%=basePath%>cca/list',
            reader: {   //这里的reader为数据存储组织的地方，下面的配置是为json格式的数据，例如：[{"total":50,"rows":[{"a":"3","b":"4"}]}]
                type: 'json', //返回数据类型为json格式
                root: 'result.list',  //数据
                totalProperty: 'result.total' //数据总条数
            }
        },
        sorters: [{
			property: 'ordeId',
			direction: 'desc'
		}],
		 autoLoad: true  //即时加载数据
		//autoLoad:{start:0,limit:5},  //即时加载数据
    });
    
   
//新建的列表
    var grid = Ext.create('Ext.grid.Panel', {
    renderTo: "aa",
    id:'grid',
    store: store,
    height: 400,
    width:"100%",
    
    selModel:Ext.create('Ext.selection.CheckboxModel',{mode:"SIMPLE"}),
    //selModel: { selType: 'checkboxmodel' },   //选择框
    columns: [                    
                  { text: 'ID', dataIndex: 'ID',  maxWidth: 700 ,hidden:true, },
                  { text: '货物种类', dataIndex: 'GOODS_TYPE',  maxWidth: 140,},
                  { text: '江船公司', dataIndex: 'RIVER_BOAT_COMPANY', align: 'left', minWidth: 180, },
                  { text: '箱主', dataIndex: 'BOX_MASTER', maxWidth: 120, align: 'left', }, 
                  { text: '起点港', dataIndex: 'START_PORT', maxWidth: 150, align: 'left',  }, 
                  { text: '终点港', dataIndex: 'END_PORT', maxWidth: 150, align: 'left', }, 
                  { text: '费用名称', dataIndex: 'FRR_NAME', maxWidth: 120, align: 'left',  }, 
                  { text: '货币类型', dataIndex: 'CURRENCY_TYPE', maxWidth: 80, align: 'left', }, 
                  { text: '汇率', dataIndex: 'EXCHANGE_RATE', maxWidth: 80, align: 'left',  }, 
                  { text: '收付款标志', dataIndex: 'COLLECT_PAYMENT_SIGN', maxWidth: 1300, align: 'left',  }, 
                  { text: '结算单位', dataIndex: 'SETTLE_UNIT', maxWidth: 250, align: 'left', },  
                  { text: '税率', dataIndex: 'TAX_RATE', maxWidth: 140, align: 'left', }, 
                  { text: '箱型代码', dataIndex: 'BOX_TYPE_CODE', maxWidth: 80, align: 'left', }, 
                  { text: '单价', dataIndex: 'UNIT_PRICE', maxWidth: 80, align: 'left', }, 
                  { text: '空重箱', dataIndex: 'EMPTY_BOX', maxWidth: 80, align: 'left' },
                  { text: '进出口标志', dataIndex: 'IMPORT_AND_EXPORT_SIGN', maxWidth: 80, align: 'left' }, 
                  { text: '是否可用', dataIndex: 'ENABLE', maxWidth: 80, align: 'left' }, 
                  { text: '备注', dataIndex: 'REMARK', maxWidth: 890, align: 'left' }, 
                  { text: '航线', dataIndex: 'ROUTE_CODE', maxWidth: 80, align: 'left' }, 
                  { text: '开始时间', dataIndex: 'START_PRICE_TIME', maxWidth: 80, align: 'left',format:'y-m-d' }, 
                  { text: '结束时间', dataIndex: 'END_PRICE_TIME', maxWidth: 80, align: 'left',format: 'Y-m-d' }, 
                 
               ],
    bbar: [{
        xtype: 'pagingtoolbar',
        store: store,
        displayMsg: '显示 {0} - {1} 条，共计 {2} 条',
        emptyMsg: "没有数据",
        beforePageText: "当前页",
        afterPageText: "共{0}页",
        displayInfo: true,
   
       // pageSize:5
    }],
  
    tbar:[
          {text:'新增',iconCls:'a_add',handler:showAlert},"-",
          {text:'编辑',iconCls:'a_edit2',handler:showAler},
          {text:'删除',iconCls:'a_edit2',handler:showAle},
          {text:'批量修改结算单位',iconCls:'a_edit2',handler: show},
          
          {text:'导入',iconCls:'a_edit2',handler : toImport,}
          ], 
     
});


  //导入excel
  function toImport(){
//   	 if(Ext.getCmp('grid').getSelectionModel().getSelection().length == 0){
//   		  Ext.MessageBox.alert("提示", "请选择箱号录入里一条记录！");
//   	      return;
//   	  }
//   	 if(Ext.getCmp('grid').getSelectionModel().getSelection().length > 1){
//   			Ext.Msg.alert("提示","请选择箱号录入里一条记录");return;
//   		}
      impWin.show();
  }
  var uploadForm = Ext.create('Ext.form.Panel', {
      items: [
          {
              xtype: 'filefield',
              fieldLabel: '文件上传',
              name:"file",
              labelWidth: 80,
              msgTarget: 'side',
              allowBlank: false,
              emptyText: "请选择上传文件",
              blankText:"请选择上传文件",
              margin: '10,10,10,10',
              anchor: '100%',
              buttonText:'选择文件'
          }],
      buttonAlign:'center'

  });


  var impWin = Ext.create('Ext.window.Window', {
      title: 'CCA费用',
      modal : true,
      items: [uploadForm],
      closeAction: 'hide',
      closeable: true,
      iconCls: 'modalWin',
      buttonAlign: 'center',
      buttons: [
          {text: '导入',handler: function() { impSubmit(); }},
          {text: '关闭', handler: function() { impWin.close(); }},
          {text: '下载模板', handler: function() { CCADownload(); }}
      ]
  });

  function impSubmit(){
      uploadForm.getForm().submit({
          url:'<%=basePath%>cca/ccadaoru',  
          success: function(form, action) {
              var jsonResult = Ext.JSON.decode(action.response.responseText);
              if (jsonResult.success && jsonResult.code == "200") {
                  Ext.Msg.alert("提示","导入成功！",function(){
                      store.reload();
                      impWin.close();
                  });
              }else{
                  Ext.Msg.alert("提示","导入操作失败，请检查文件内容是否正确！");
              }
          }
      });
  }
  
//下载模板
	function CCADownload(){
		document.location.href="<%=basePath%>cca/downExcel";	

	}
	function  show(){
		var records = grid.getSelectionModel().getSelection();
		if(records.length==0){
     			Ext.Msg.alert("提示","请选择需要修改结算单位的记录");return;
     		}
		
		var SETTLE_UNIT = Ext.getCmp('e').getValue();
		//alert(SETTLE_UNIT);
		if(SETTLE_UNIT==null||SETTLE_UNIT==""){
			Ext.Msg.alert("提示","请填写结算单位");return;
		}
		var array = [];
			Ext.each(records,function(item){
				
				
				obj = {
						id:item.data.ID,
						SETTLE_UNIT:SETTLE_UNIT,
				};
				array.push(obj);
				
				});
			var array = JSON.stringify(array);
				
				Ext.Ajax.request({
					url:'<%=basePath%>cca/updateInfo',
					params:{
						array:array
					},
					timeout:5000,
					success:function(response){
						Ext.Msg.alert("提示","成功!");
						store.load();
					},
					failure:function(response){
						Ext.Msg.alert("提示","请求成分!");
						store.load();
					}
				});
	}
    //新增   
    function showAlert (){
    win.show();
    }
    //日期控件
    function convertDate(val) {
			return Ext.util.Format.date(new Date(val), 'Y-m-d');
		}

//修改
function showAler (){
	 var records = grid.getSelectionModel().getSelection();//获取选中一行的值
   	 if(records.length==0){
     			Ext.Msg.alert("提示","请选择需要编辑的记录");return;
     		}
     		if(records.length>1){
     			Ext.Msg.alert("提示","只能编辑一条记录");return;
     		}
     		
     		var ID = records[0].data.ID;
            Ext.getCmp("ID").setValue(ID);
     		
			var SETTLE_UNIT = records[0].data.SETTLE_UNIT;
     		Ext.getCmp("SETTLE_UNIT").setValue(SETTLE_UNIT);
     		
     		var BOX_MASTER = records[0].data.BOX_MASTER;
     		Ext.getCmp("BOX_MASTER").setValue(BOX_MASTER);
     		
     		var START_PORT = records[0].data.START_PORT;
     		Ext.getCmp("START_PORT").setValue(START_PORT);
     		
     		var END_PORT = records[0].data.END_PORT;
     		Ext.getCmp("END_PORT").setValue(END_PORT);
     		
     		var CURRENCY_TYPE = records[0].data.CURRENCY_TYPE;
     		Ext.getCmp("CURRENCY_TYPE").setValue(CURRENCY_TYPE);
     		
     		
     		var TAX_RATE = records[0].data.TAX_RATE;
     		Ext.getCmp("TAX_RATE").setValue(TAX_RATE);
     		
     		var EXCHANGE_RATE = records[0].data.EXCHANGE_RATE;
     		Ext.getCmp("EXCHANGE_RATE").setValue(EXCHANGE_RATE);
     		
     		var UNIT_PRICE = records[0].data.UNIT_PRICE;
     		Ext.getCmp("UNIT_PRICE").setValue(UNIT_PRICE);
     		
     		var COLLECT_PAYMENT_SIGN = records[0].data.COLLECT_PAYMENT_SIGN;
     		Ext.getCmp("COLLECT_PAYMENT_SIGN").setValue(COLLECT_PAYMENT_SIGN);
     		
     		var FRR_NAME = records[0].data.FRR_NAME;
     		Ext.getCmp("FRR_NAME").setValue(FRR_NAME);
     		
     		var EMPTY_BOX = records[0].data.EMPTY_BOX;
     		Ext.getCmp("EMPTY_BOX").setValue(EMPTY_BOX);
     		
     		var IMPORT_AND_EXPORT_SIGN = records[0].data.IMPORT_AND_EXPORT_SIGN;
     		Ext.getCmp("IMPORT_AND_EXPORT_SIGN").setValue(IMPORT_AND_EXPORT_SIGN);
     		
     		var GOODS_TYPE = records[0].data.GOODS_TYPE;
     		Ext.getCmp("GOODS_TYPE").setValue(GOODS_TYPE);
     		
     		var RIVER_BOAT_COMPANY = records[0].data.RIVER_BOAT_COMPANY;
     		Ext.getCmp("RIVER_BOAT_COMPANY").setValue(RIVER_BOAT_COMPANY);
     		
     		var REMARK = records[0].data.REMARK;
     		Ext.getCmp("REMARK").setValue(REMARK);
     		
     		var ENABLE = records[0].data.ENABLE;
     		Ext.getCmp("ENABLE").setValue(ENABLE);
     		
     		var ROUTE_CODE = records[0].data.ROUTE_CODE;
     		Ext.getCmp("ROUTE_CODE").setValue(ROUTE_CODE);
     		
     		var BOX_TYPE_CODE = records[0].data.BOX_TYPE_CODE;
     		Ext.getCmp("BOX_TYPE_CODE").setValue(BOX_TYPE_CODE);
     		
     		var START_PRICE_TIME = records[0].data.START_PRICE_TIME;
     		Ext.getCmp("START_PRICE_TIME").setValue(START_PRICE_TIME);
     		
     		var END_PRICE_TIME = records[0].data.END_PRICE_TIME;
     		Ext.getCmp("END_PRICE_TIME").setValue(END_PRICE_TIME);

	       win.show();
	}
	//删除
	function  showAle(){
		var records = grid.getSelectionModel().getSelection();
 		if(records.length==0){
 			Ext.Msg.alert("提示","请选中需要删除的记录");return;
 			}
 			var arr = [];
 			Ext.each(records,function(item){
 				obj = {
 						id:item.data.ID
 						
 				};
 				arr.push(obj);
 				
 			});
 			var array = JSON.stringify(arr);
 			Ext.Ajax.request({
 						url:  '<%=basePath%>cca/dele',
						params:{
							array:array		
						},
						timeout:5000,
						success:function(response){
							 Ext.MessageBox.alert("删除","删除成功");
								var store = Ext.getCmp('grid').getStore();
							 store.reload();
						},
						
					});
 	}
	
	//保存按钮
	var save = new Ext.Button({
     	text: '保存',
     	 handler: function(){
     		add.getForm().isValid();  
//      		var START_PRICE_TIME = Ext.getCmp('START_PRICE_TIME').getValue();
//      		alert(START_PRICE_TIME)

                     var form = Ext.getCmp('add').getForm();
                    if (form.isValid()) {
			
	                        form.submit({
		             url: '<%=basePath%>cca/save',
		                   params : {
		                	
		                   },		
	                            success: function(form, action) {
	                               Ext.Msg.alert('提示信息',"成功");
	                             win.close();
		                        store.load();
	                            },
	                            
	                        });
}else{
	Ext.Msg.alert('提示信息', "保存失败，请输入正确的税率和汇率和单价");
}
//      		var SETTLE_UNIT = Ext.getCmp('SETTLE_UNIT').getValue();
//      		var BOX_MASTER = Ext.getCmp('BOX_MASTER').getValue();
//      		var START_PORT = Ext.getCmp('START_PORT').getValue();
//      		var END_PORT = Ext.getCmp('END_PORT').getValue();
//      		var CURRENCY_TYPE = Ext.getCmp('CURRENCY_TYPE').getValue();
//      		var TAX_RATE = Ext.getCmp('TAX_RATE').getValue();
//      		var EXCHANGE_RATE = Ext.getCmp('EXCHANGE_RATE').getValue();
     		

// 			var UNIT_PRICE = Ext.getCmp('UNIT_PRICE').getValue();

// 			var COLLECT_PAYMENT_SIGN = Ext.getCmp('COLLECT_PAYMENT_SIGN').getValue();

//      		var FRR_NAME = Ext.getCmp('FRR_NAME').getValue();

//      		var EMPTY_BOX = Ext.getCmp('EMPTY_BOX').getValue();

//      		var IMPORT_AND_EXPORT_SIGN = Ext.getCmp('IMPORT_AND_EXPORT_SIGN').getValue();
//      		var GOODS_TYPE = Ext.getCmp('GOODS_TYPE').getValue();
//      		var RIVER_BOAT_COMPANY = Ext.getCmp('RIVER_BOAT_COMPANY').getValue();
//      		var REMARK = Ext.getCmp('REMARK').getValue();
//      		alert(REMARK)
//      		var ENABLE = Ext.getCmp('ENABLE').getValue();
//      		var ROUTE_CODE = Ext.getCmp('ROUTE_CODE').getValue();
//      		var BOX_TYPE_CODE = Ext.getCmp('BOX_TYPE_CODE').getValue();

// 			var store = Ext.getCmp('grid').getStore();
// 	  		 Ext.Ajax.request({
<%--      			 url: '<%=basePath%>cca/save', --%>
// 					params : {
// 						ID : ID,
// 						SETTLE_UNIT : SETTLE_UNIT,
// 						BOX_MASTER : BOX_MASTER,
// 						START_PORT : START_PORT,
// 						END_PORT : END_PORT,
// 						CURRENCY_TYPE : CURRENCY_TYPE,
// 						TAX_RATE : TAX_RATE,
// 						EXCHANGE_RATE : EXCHANGE_RATE,
// 						UNIT_PRICE : UNIT_PRICE,
// 						COLLECT_PAYMENT_SIGN : COLLECT_PAYMENT_SIGN,
// 						FRR_NAME : FRR_NAME,
// 						EMPTY_BOX : EMPTY_BOX,
// 						IMPORT_AND_EXPORT_SIGN : IMPORT_AND_EXPORT_SIGN,
// 						GOODS_TYPE : GOODS_TYPE,
// 						RIVER_BOAT_COMPANY : RIVER_BOAT_COMPANY,
// 						REMARK : REMARK,
// 						ENABLE : ENABLE,
// 						ROUTE_CODE : ROUTE_CODE,
// 						BOX_TYPE_CODE : BOX_TYPE_CODE,
// 					},
// 					method : 'POST',
// 					success : function() {
// 						Ext.MessageBox.alert("保存成功", "保存成功");
                         
// 						win.close();
// 						store.load();
// 					},
// 				});

			}

		});
	//重置按钮
		var reset = new Ext.Button({
			text : '重置',
			listeners : {
				'click' : function() {
					Ext.getCmp('add').form.reset();
				
				}
			}
		}

		);
	//取消按钮
		var cancel = new Ext.Button({
			text : '取消',
			listeners : {
				'click' : function() {
					win.close();
				}
			}
		}

		);
	     //是否可用下拉
		var enable = Ext.create('Ext.data.Store', {
			fields: ['id', 'name'],
			data : [
                {"id":"", "name":"选择是否可用"},
				{"id":"1", "name":"是"},
				{"id":"0", "name":"否"},
				
			]
		});
	     //收付款标志下拉
		var shoufu = Ext.create('Ext.data.Store', {
			fields: ['id', 'name'],
			data : [
                {"id":"", "name":"选择收付款标志"},
				{"id":"0", "name":"付"},
				{"id":"1", "name":"收"},
				
			]
		});
		  //进出口下拉
		var jinchukou = Ext.create('Ext.data.Store', {
			fields: ['id', 'name'],
			data : [
                {"id":"", "name":"选择进出口标志"},
				{"id":"0", "name":"进口"},
				{"id":"1", "name":"出口"},
				
			]
		});
		  //空重箱
		var kongzhongxiang = Ext.create('Ext.data.Store', {
			fields: ['id', 'name'],
			data : [
                {"id":"", "name":"选择空重箱"},
				{"id":"0", "name":"空"},
				{"id":"1", "name":"重"},
				
			]
		});
	     //货币类型
		var tuoStore = Ext.create('Ext.data.Store', {
			fields: ['id', 'name'],
			data : [
                {"id":"", "name":"选择货币类型"},
				{"id":"RMB", "name":"PMB"},
				{"id":"USD", "name":"USD"},
				
				
			]
		});
		var c2 = Ext.create('Ext.container.Container', {
		    layout: 'column',
		    defaults: { labelAlign: 'left', labelWidth: 65 },
		    items: [
		        {id : 'ID',hidden : true,hideLabel : true,xtype : 'textfield',fieldLabel : 'ID',name : 'ID'},  
		        {id : 'GOODS_TYPE',fieldLabel : '货物种类',name : 'GOODS_TYPE',xtype : 'textfield',columnWidth: .5,emptyText:'请输入货物种类',allowBlank: false,}, 
		        {id : 'RIVER_BOAT_COMPANY',fieldLabel : '江船公司',name : 'RIVER_BOAT_COMPANY',xtype : 'textfield',columnWidth: .5,emptyText:'请输入江船公司',allowBlank: false,},
		    ]
		});
		var c3 = Ext.create('Ext.container.Container', {
		    layout: 'column',
		    defaults: { labelAlign: 'left', labelWidth: 65 },
		    items: [
						{id : 'BOX_MASTER',fieldLabel : '箱主',name : 'BOX_MASTER',xtype : 'textfield',columnWidth: .5,emptyText:'请输入箱主',allowBlank: false,},
						{id : 'START_PORT',fieldLabel : '起点港',name : 'START_PORT',xtype : 'textfield',columnWidth: .5,emptyText:'请输入起点港',allowBlank: false,},
		    ]
		});
		var c4 = Ext.create('Ext.container.Container', {
		    layout: 'column',
		    defaults: { labelAlign: 'left', labelWidth: 65 },
		    items: [
						{id : 'END_PORT',fieldLabel : '终点港',name : 'END_PORT',xtype : 'textfield',columnWidth: .5,emptyText:'请输入终点港',allowBlank: false,},
						{id : 'FRR_NAME',fieldLabel : '费用名称',name : 'FRR_NAME',xtype : 'textfield',columnWidth: .5,emptyText:'请输入费用名称',allowBlank: false,},
		    ]
		});
		
		var c5 = Ext.create('Ext.container.Container', {
		    layout: 'column',
		    defaults: { labelAlign: 'left', labelWidth: 65 },
		    items: [
						{id : 'EXCHANGE_RATE',fieldLabel : '汇率',name : 'EXCHANGE_RATE',xtype : 'textfield',
							regex:/^^(\-|\+)?\d+(\.\d+)?$$/,regexText : "请输入正确的汇率",columnWidth: .5,emptyText:'请输入汇率',allowBlank: false,},          
						{id : 'SETTLE_UNIT',fieldLabel : '结算单位',name : 'SETTLE_UNIT',xtype : 'textfield',columnWidth: .5,emptyText:'请输入结算单位',allowBlank: false,},

		    ]
		});
		
		var c6 = Ext.create('Ext.container.Container', {
		    layout: 'column',
		    defaults: { labelAlign: 'left', labelWidth: 65 },
		    items: [
					  {id : 'TAX_RATE',fieldLabel : '税率',name : 'TAX_RATE',xtype : 'textfield',
						  regex:/^^(\-|\+)?\d+(\.\d+)?$$/,regexText : "请输入正确的税率",columnWidth: .5,emptyText:'请输入税率',allowBlank: false,},
					  {id:'COLLECT_PAYMENT_SIGN',fieldLabel : '收付款',name : 'COLLECT_PAYMENT_SIGN',xtype : 'combobox',
		                    store : shoufu,valueField: 'id',displayField:'name',editable: false,allowBlank: false,columnWidth: .5, emptyText:'请选择',},
		        
		    ]
		});
		
		var c7 = Ext.create('Ext.container.Container', {
		    layout: 'column',
		    defaults: { labelAlign: 'left', labelWidth: 65 },
		    items: [
					 {id:'CURRENCY_TYPE',fieldLabel : '货币类型',name : 'CURRENCY_TYPE',xtype : 'combobox',store : tuoStore,valueField: 'id',displayField:'name',editable: false,allowBlank: false,columnWidth: .5,emptyText:'请选择',},
					 {id : 'BOX_TYPE_CODE',fieldLabel : '箱型代码',maxLength:5,name : 'BOX_TYPE_CODE',xtype : 'textfield',columnWidth: .5,emptyText:'请输入箱型代码',allowBlank: false,},
		        ]
		});
		
		var c8 = Ext.create('Ext.container.Container', {
		    layout: 'column',
		    defaults: { labelAlign: 'left', labelWidth: 65 },
		    items: [
		        	{id : 'UNIT_PRICE',fieldLabel : '单价',name : 'UNIT_PRICE',xtype : 'textfield',regex:/^^(\-|\+)?\d+(\.\d+)?$$/,regexText : "请输入正确的单价",columnWidth: .5,emptyText:'请输入单价',allowBlank: false,},
					{id : 'EMPTY_BOX',fieldLabel : '空重箱',name : 'EMPTY_BOX',xtype : 'combobox',store : kongzhongxiang,valueField: 'id',displayField:'name',editable: false,allowBlank: false,columnWidth: .5,emptyText:'请选择',},
		    ]
		});
		var c9 = Ext.create('Ext.container.Container', {
		    layout: 'column',
		    defaults: { labelAlign: 'left', labelWidth: 65 },
		    items: [  
		              {id : 'IMPORT_AND_EXPORT_SIGN',fieldLabel : '进出口标志',name : 'IMPORT_AND_EXPORT_SIGN',xtype : 'combobox',store : jinchukou,valueField: 'id',displayField:'name',editable: false,allowBlank: false,columnWidth: .5,emptyText:'请选择',},
					  {id : 'ENABLE',fieldLabel : '是否可用',name : 'ENABLE',xtype : 'combobox',store : enable,valueField: 'id',displayField:'name',editable: false,allowBlank: false,columnWidth: .5,emptyText:'请选择',},
		    ]
		});
		var c10 = Ext.create('Ext.container.Container', {
		    layout: 'column',
		    defaults: { labelAlign: 'left', labelWidth: 65 },
		    items: [
		            {id : 'REMARK',fieldLabel : '备注',name : 'REMARK',xtype : 'textfield',columnWidth: .5,emptyText:'请输入备注',},
					{id : 'ROUTE_CODE',fieldLabel : '航线',name : 'ROUTE_CODE',xtype : 'textfield',columnWidth: .5,emptyText:'请输入航线',allowBlank: false,},
		    		]
		});
		var c11 = Ext.create('Ext.container.Container', {
		    layout: 'column',
		    defaults: { labelAlign: 'left', labelWidth: 65 },
		    items: [
		            {id : 'START_PRICE_TIME',fieldLabel : '开始时间',name : 'START_PRICE_TIME',xtype : 'datefield',format: 'Y-m-d',columnWidth: .5,editable: false,emptyText:'请选择',allowBlank: false},
					{id : 'END_PRICE_TIME',fieldLabel : '结束时间',name : 'END_PRICE_TIME',xtype : 'datefield',format: 'Y-m-d',columnWidth: .5,editable: false,emptyText:'请选择',allowBlank: false},
		    		]
		});

	//新增一个form表单
		var add = Ext.create("Ext.form.Panel", {
             id:'add',
			frame : true,
			width : 695,
			height : 300,

			defaults : {
				anchor : '100%',
				labelWidth : 50,
				labelAlign : "right"
			},
			
			 items: [c2,c3,c4,c5,c6,c7,c8,c9,c10,c11]
		
		});
        //新建一个窗口，把form表单放进去
		var win = Ext.create("Ext.window.Window", {
			title : '新增',
			width : 700,
			height : 300,  
			resizable : true,
			modal : true,
			closable : true,
			maximizable : true,
			minimizable : true,
			closeAction :'hide',
			buttons : [ save, reset, cancel ],
			items : [ add ],
		});
		       
        //新建查询列表
		var c1 = Ext.create('Ext.container.Container', {
			layout : 'column',
			
			defaults : {
				labelAlign : 'left',
				labelWidth : 60
			},
			items : [
					{
						xtype : 'textfield',
						name : 'BOX_MASTER',
						id : 'a',
						columnWidth : 1 / 4,
						padding : '5px',
						fieldLabel : '箱主',
						emptyText:'请输入箱主',
					},
					{
						xtype : 'textfield',
						name : 'FRR_NAME',
						id : 'b',
						columnWidth : 1 / 4,
						padding : '5px',
						fieldLabel : '费用名称'
							,emptyText:'请输入费用名称',
					},
					{
						xtype : 'textfield',
						name : 'START_PORT',
						id : 'c',
						columnWidth : 1 / 4,
						padding : '5px',
						fieldLabel : '起点港'
							,emptyText:'请输入起点港',
					},
					{
						xtype : 'textfield',
						name : 'END_PORT',
						id : 'd',
						columnWidth : 1 / 4,
						padding : '5px',
						fieldLabel : '终点港'
							,emptyText:'请输入终点港',
					},
					{
						xtype : 'textfield',
						name : 'SETTLE_UNIT',
						id : 'e',
						columnWidth : 1 / 4,
						padding : '5px',
						fieldLabel : '结算单位'
							,emptyText:'请输入结算单位',
					},
					{
						xtype : 'textfield',
						name : 'BOX_TYPE_CODE',
						id : 'f',
						columnWidth : 1 / 4,
						padding : '5px',
						fieldLabel : '箱型代码'
							,emptyText:'请输箱型代码',
					},
					
					{
						xtype : 'combobox',
						name : 'EMPTY_BOX',
						id : 'g',
						columnWidth : 1 / 4,
						padding : '5px',
						fieldLabel : '空重箱',
						emptyText:'请选择',
						store :kongzhongxiang ,
						valueField: 'id',
						displayField:'name',
						editable: false,
					},
					{
						xtype : 'combobox',
						name : 'COLLECT_PAYMENT_SIGN',
						id : 'h',
						columnWidth : 1 / 4,
						padding : '5px',
						fieldLabel : '收付款',
						emptyText:'请选择',
						store : shoufu,
						valueField: 'id',
						displayField:'name',
						editable: false,
					},
					{
						xtype : 'combobox',
						name : 'CURRENCY_TYPE',
						id : 'i',
						columnWidth : 1 / 4,
						padding : '5px',
						fieldLabel : '货币类型',
						emptyText:'请选择',
						store : tuoStore,
						valueField: 'id',
						displayField:'name',
						editable: false,
					},
					{
						xtype : 'datefield',
						name : 'START_PRICE_TIME',
						id : 'starttime',
						columnWidth : 1 / 4,
						padding : '5px',
						fieldLabel : '开始时间',
						editable: false,
					},
					{
						xtype : 'datefield',
						name : 'END_PRICE_TIME',
						id : 'endtime',
						columnWidth : 1 / 4,
						padding : '5px',
						fieldLabel : '结束时间',
						editable: false,
					},
					{
						xtype : "button",
						padding : '5px',
						text : '查询',
						handler : function() {
					var BOX_MASTER = Ext.getCmp('a').getValue();//箱主
				//	alert(BOX_MASTER)
				
					var FRR_NAME = Ext.getCmp('b').getValue();//费用名称
				// alert(FRR_NAME)
					
					var START_PORT = Ext.getCmp('c').getValue();//起点港
				//	alert(START_PORT)
					
				    var END_PORT = Ext.getCmp('d').getValue();//终点港
				//	alert(END_PORT)
					
					var SETTLE_UNIT = Ext.getCmp('e').getValue();//结算单位
				 //  alert(SETTLE_UNIT)
				    
					var BOX_TYPE_CODE = Ext.getCmp('f').getValue(); //箱型代码
				   //  alert(BOX_TYPE_CODE)
				     
					var EMPTY_BOX = Ext.getCmp('g').getValue(); //空重箱
				   // alert(EMPTY_BOX)
					
				    var COLLECT_PAYMENT_SIGN = Ext.getCmp('h').getValue(); //收付款
				   // alert(COLLECT_PAYMENT_SIGN)
				   var CURRENCY_TYPE = Ext.getCmp('i').getValue(); //货币类型
				    //alert(CURRENCY_TYPE)
                   var START_PRICE_TIME = Ext.getCmp('starttime').getValue(); //开始时间
				    //alert(START_PRICE_TIME)
				    
				     var END_PRICE_TIME = Ext.getCmp('endtime').getValue(); //结束时间
				  // alert(END_PRICE_TIME)
					var store = Ext.getCmp('grid').getStore();
					store.on('beforeload', function(store, options) {
						var new_params = {
								BOX_MASTER : BOX_MASTER, //箱主
								FRR_NAME : FRR_NAME, //起运港
								START_PORT : START_PORT,  //目的港
								END_PORT : END_PORT,//货物名称
								SETTLE_UNIT : SETTLE_UNIT, //中文品名
								BOX_TYPE_CODE : BOX_TYPE_CODE, //委托单位
								EMPTY_BOX : EMPTY_BOX, //提单号
								COLLECT_PAYMENT_SIGN : COLLECT_PAYMENT_SIGN, //预配箱主
								CURRENCY_TYPE : CURRENCY_TYPE, //币种类型
								START_PRICE_TIME : START_PRICE_TIME,
								END_PRICE_TIME : END_PRICE_TIME,
						};
						Ext.apply(store.proxy.extraParams, new_params);
					});
					store.load();
				}
			},{
				xtype : "button",
				padding : '6px',
				text : '清空信息',
				listeners : {
					'click' : function() {
						
						Ext.getCmp('re').form.reset();
					
					}
				}
				
			}
					
					]

		});
           //把查询的列表放进form中
		var form = Ext.create('Ext.form.Panel', {
			renderTo : 'div1',
			frame : true,
			id:'re',
			items : [ c1 ],

 		});

	});



</script>
</html>